Skip to content

Add native GitHub Copilot inline completions#2182

Draft
anxkhn wants to merge 1 commit into
CodeEditApp:mainfrom
anxkhn:feat/copilot
Draft

Add native GitHub Copilot inline completions#2182
anxkhn wants to merge 1 commit into
CodeEditApp:mainfrom
anxkhn:feat/copilot

Conversation

@anxkhn

@anxkhn anxkhn commented Jun 30, 2026

Copy link
Copy Markdown

Description

Adds native GitHub Copilot inline completions to CodeEdit. As you type, the editor shows AI ghost text suggestions and accepts them with Tab. This is the app-level integration on top of the inline suggestion rendering primitive (CodeEditTextView) and the inline completion coordination layer (CodeEditSourceEditor).

What's added:

  • CopilotClient / CopilotService / CopilotProtocol: launches and talks to the official copilot-language-server over LSP, with device-flow sign-in, status, and document sync.
  • CopilotInlineCompletionProvider: a per-document InlineCompletionDelegate that maps the caret to an LSP position, requests completions, strips already-typed prefixes, and adapts results into the editor's ghost-text model. Suggestions render via the CodeEditTextView overlay and never mutate the document until accepted.
  • CopilotBinaryResolver: locates copilot-language-server (explicit path, PATH, or common install dirs) and builds a launch environment that can find node, including nvm installs, since the server is a Node script.
  • A Settings page (enable toggle, device-flow sign-in UI, optional language-server path) and a status bar item reflecting Copilot state.
  • Wiring in CodeFileDocument / CodeFileView to attach the provider per open document.
  • Disabled by default; opt-in via Settings. Requires a GitHub Copilot subscription.

Related Issues

Draft: this builds against local checkouts of the two dependency branches via a workspace. It cannot build in CI until those land and are released; the CodeEditTextView and CodeEditSourceEditor package pins then need bumping. Marking ready once that is possible.

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

I will attach a screen recording of the device-flow sign-in and inline ghost text (request, multi-line preview, and Tab to accept).

Testing

  • Built and run locally against the two dependency branches via a workspace referencing local checkouts.
  • Verified end to end against the real copilot-language-server: device-flow sign-in, inline ghost text as you type, and Tab to accept.
  • SwiftLint: 0 violations (strict) on all changed files.

Integrate the GitHub Copilot language server to provide AI inline
completions (ghost text) in the editor, building on the inline-suggestion
primitive in CodeEditTextView and the InlineCompletionDelegate seam in
CodeEditSourceEditor.

New Features/Copilot group:
- CopilotService: @mainactor ObservableObject singleton that owns the
  language-server process and lifecycle, publishes auth state
  (signedOut / awaitingDeviceCode / signedIn / error) and a busy flag,
  and brokers document sync and inline-completion requests. Resolves the
  binary from settings or PATH.
- CopilotClient: raw JSON-RPC transport over a framed JSONRPCSession that
  drives Copilot's custom methods (initialize, signIn, checkStatus,
  textDocument/inlineCompletion, telemetry) and answers server-to-client
  requests (workspace/configuration, workDoneProgress/create,
  showDocument) plus didChangeStatus/v2.
- CopilotProtocol: Codable param/result types for the custom methods.
- CopilotInlineCompletionProvider: implements InlineCompletionDelegate,
  syncs the document, maps the cursor to an LSP position, and adapts
  server items to ghost text (prefix-stripping, newline normalization).
- CopilotDocumentObjects: per-document bundle that owns the provider so
  the controller's weak delegate reference survives.

Wire-up:
- Register CopilotService alongside LSPService in CodeEditApp.
- Add a Copilot settings page (enable toggle, language-server path,
  device-flow sign-in/out with live status) and SettingsData/SettingsPage
  entries.
- Add a status bar item reflecting Copilot state.
- Pass the inline completion delegate from CodeFileView when enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native GitHub Copilot inline completions

1 participant